package jsyf.oa.web.report;

import com.alibaba.fastjson.JSONObject;
import io.swagger.annotations.Api;
import jsyf.com.util.BaseUtils;
import jsyf.com.util.FastJsonConvert;
import jsyf.com.util.ResponseUtils;
import jsyf.oa.facade.report.UserReportFacade;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * Created by Administrator on 2018/1/23 0023.
 */
@Api(value = "人员报表接口", description = "人员报表接口")
@Controller
@RequestMapping("/reportUser")
public class UserReportController {

    @Resource
    private UserReportFacade userReportFacade;

    @RequestMapping(value = "/user.json", method = RequestMethod.POST)
    public void getUserByUserId(HttpServletRequest request, HttpServletResponse response, @RequestBody String jsonData) {
        JSONObject jsonParams = FastJsonConvert.convertJSONToObject(jsonData, JSONObject.class);
        String userId = jsonParams.getString("userId");
        JSONObject records = this.userReportFacade.getByUserId(userId);
        ResponseUtils.putJsonResponse(response, BaseUtils.succsessObjRespond(records));
    }
}
